package com.od.message.protocol;

import org.msgpack.annotation.Message;

/**
 * IMMessage:消息实体类，用于封装自定义协议的消息内容。
 * +-------------------------------------------------------+
 * |下行命令：服务端向客户端发送的消息                           |
 * |-------------------------------------------------------|
 * |  SYSTEM  | 系统命令：[命令][发送时间][接收人] - 消息内容     |
 * |-------------------------------------------------------|
 * |上行命令：客户端向服务端发送的消息                           |
 * |------------------------------------------------------|
 * |   LOGIN  | 登录动作：[命令][发送时间][发信人]             |
 * |------------------------------------------------------|
 * |  LOGOUT  | 退出登录：[命令][发送时间][发信人]             |
 * |-----------------------------------------------------|
 * |  CHAT   | 聊天：[命令][发送时间][发信人][接收人]-消息内容  |
 * +-----------------------------------------------------|
 * |  FLOWER | 送花：[命令][发送时间][发信人][收信人]         |
 * +----------------------------------------------------|
 */
@Message
public class IMMessage {
    private String addr;
    private String cmd;
    private long time;
    private int online;
    private String sender;
    private String receiver;
    private String content;
    private String terminal;

    public IMMessage() {
    }

    public IMMessage(String cmd, long time, int online, String content) {
        this.cmd = cmd;
        this.time = time;
        this.online = online;
        this.content = content;
        this.terminal = terminal;
    }

    public IMMessage(String cmd, String terminal, long time, String sender) {
        this.cmd = cmd;
        this.time = time;
        this.sender = sender;
        this.terminal = terminal;
    }

    public IMMessage(String cmd, long time, String sender, String content) {
        this.cmd = cmd;
        this.time = time;
        this.sender = sender;
        this.content = content;
        this.terminal = terminal;
    }

    @Override
    public String toString() {
        return "IMMessage{" +
                "addr='" + addr + '\'' +
                ", cmd='" + cmd + '\'' +
                ", time=" + time +
                ", online=" + online +
                ", sender='" + sender + '\'' +
                ", receiver='" + receiver + '\'' +
                ", content='" + content + '\'' +
                ", terminal='" + terminal + '\'' +
                '}';
    }

    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr;
    }

    public String getCmd() {
        return cmd;
    }

    public void setCmd(String cmd) {
        this.cmd = cmd;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public int getOnline() {
        return online;
    }

    public void setOnline(int online) {
        this.online = online;
    }

    public String getSender() {
        return sender;
    }

    public void setSender(String sender) {
        this.sender = sender;
    }

    public String getReceiver() {
        return receiver;
    }

    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getTerminal() {
        return terminal;
    }

    public void setTerminal(String terminal) {
        this.terminal = terminal;
    }
}
